package com.team.sns.entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
 * 
 * @author lyh
 * version 1.0
 * 权限管理
 */
@Entity
public class Permissions implements Serializable{
	
	private static final long serialVersionUID = 1L;
	
	private Integer id;
	
	private String name;
	
	private String description;
	
	private Date created;
	
	private String action;
	
	private String parent;
	
	private List<Actor> actors = new ArrayList<Actor>();
	
	@ManyToMany(mappedBy = "permissions", cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
	public List<Actor> getActors() {
		return actors;
	}

	public void setActors(List<Actor> actors) {
		this.actors = actors;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	@Column(length = 40, unique = true)
	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	@Column(length = 200)
	public void setDescription(String description) {
		this.description = description;
	}

	public Date getCreated() {
		return created;
	}

	@Column(length = 100, nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	public void setCreated(Date created) {
		this.created = created;
	}

	public String getAction() {
		return action;
	}

	@Column(length = 200, nullable = false)
	public void setAction(String action) {
		this.action = action;
	}

	public String getParent() {
		return parent;
	}

	@Column(length = 200)
	public void setParent(String parent) {
		this.parent = parent;
	}
	
	

}
